<%@ page contentType="text/html;charset=UTF-8" %>
<meta charset="utf-8">
<meta name="keywords" content="">
<meta name="description" content="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
<meta name="format-detection" content="telephone=no"/>
<link type="text/css" rel="stylesheet" href="${yyghStatic}/modules/yygh/font/iconfont.css?rev=2390147cc9879afc0ffec0"/>
<link type="text/css" rel="stylesheet" href="${yyghStatic}/modules/yygh/css/core.css?rev=496660e0e823d18587726d431f8"/>
<script type="text/javascript" src="${yyghStatic}/modules/yygh/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="${yyghStatic}/modules/yygh/js/common-rem1.js?rev=cc0b0688d74757885cd0f72f"></script>
<script type="text/javascript" src="${yyghStatic}/modules/yygh/js/common.js?rev=dfsdfweadfad443232356565624sfa"></script>
<script type="text/javascript" src="${yyghStatic}/modules/yygh/js/fastclick.js"></script>
<script type="text/javascript" src="${yyghStatic}/modules/yygh/lib/layer/layer.js"></script>
<script>
function checkMobile(s){
	var regu =/^[1][3|8|4|5|7][0-9]{9}$/;
	var re = new RegExp(regu);
	if (re.test(s)) {
		return true;
	}else{
		return false;
	}
}
function checkClinicCard(s){
	var regu =/^[A-Za-z0-9]+$/;
	var re = new RegExp(regu);
	if (re.test(s)) {
		return true;
	}else{
		return false;
	}
}
 function IdentityCodeValid(num) {

    var factorArr = new Array(7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1);
    var error;
    var varArray = new Array();
    var intValue;
    var lngProduct = 0;
    var intCheckDigit;
    var intStrLen = num.length;
    var idNumber = num;
    // initialize
    if ((intStrLen != 15) && (intStrLen != 18)) {
        error = "输入身份证号码长度不对！";
        showMsg(error);
        //frmAddUser.txtIDCard.focus();
        return false;
    }
    // check and set value
    for(i=0;i<intStrLen;i++) {
        varArray[i] = idNumber.charAt(i);
        if ((varArray[i] < '0' || varArray[i] > '9') && (i != 17)) {
            error = "错误的身份证号码！.";
            alert(error);
            //frmAddUser.txtIDCard.focus();
            return false;
        } else if (i < 17) {
            varArray[i] = varArray[i]*factorArr[i];
        }
    }
    if (intStrLen == 18) {
        //check date
        var date8 = idNumber.substring(6,14);
        if (checkDate(date8) == false) {
            error = "身份证中日期信息不正确！.";
            alert(error);
            return false;
        }
        // calculate the sum of the products
        for(i=0;i<17;i++) {
            lngProduct = lngProduct + varArray[i];
        }
        // calculate the check digit
        intCheckDigit = 12 - lngProduct % 11;
        switch (intCheckDigit) {
            case 10:
                intCheckDigit = 'X';
                break;
            case 11:
                intCheckDigit = 0;
                break;
            case 12:
                intCheckDigit = 1;
                break;
        }
        // check last digit
        if (varArray[17].toUpperCase() != intCheckDigit) {
            error = "身份证效验位错误!...正确为： " + intCheckDigit + ".";
            //alert(error);
            return false;
        }
    }
    else{        //length is 15
        //check date
        var date6 = idNumber.substring(6,12);
        if (checkDate(date6) == false) {
            alert("身份证日期信息有误！.");
            return false;
        }
    }
    //alert ("Correct.");
    return true;
}

function checkDate(date)
{
    return true;
}
//验证时间的yyyy-mm-dd
function rqcheck(rq) {
   var date = rq;
   var result = date.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
   if (result == null)
       return false;
   var d = new Date(result[1], result[3] - 1, result[4]);
   return (d.getFullYear() == result[1] && (d.getMonth() + 1) == result[3] && d.getDate() == result[4]);
}
</script>
